import json
from marshmallow import Schema, fields

from zeus.operation_service.database import Asset


class GetAssetPage_ResponseSchema(Schema):
    """
    Get asset page response schema
    """
    asset_name = fields.Method("get_asset_name")

    class Meta:
        model = Asset
        fields = (
            "asset_id",
            "asset_name",
            "update_time",
            "version",
            "support_type",
        )

    def get_asset_name(self, asset):
        return json.loads(asset.name)
